package comu.hnevc.zh.testdemo.fragment;

import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import comu.hnevc.zh.testdemo.MainActivity;
import comu.hnevc.zh.testdemo.R;

public class PeccancyImgFragment extends Fragment {
    private MainActivity activity;
    private Button return_btn;
    private ImageView img;
    private  int i;

    public PeccancyImgFragment() {
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_peccancy_img,container,false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        activity= (MainActivity) getActivity();
        img=activity.findViewById(R.id.id_iv_pic);
        Bundle bundle=new Bundle();
        i=bundle.getInt("i");
        Toast.makeText(activity,""+i,Toast.LENGTH_SHORT).show();
        switch (i){
            case 1:
                img.setImageResource(R.drawable.pic1);
                break;
            case 2:
                img.setImageResource(R.drawable.pic2);
                break;
            case 3:
                img.setImageResource(R.drawable.pic3);
                break;
            case 4:
                img.setImageResource(R.drawable.pic4);
                break;
        }
   return_btn.setOnClickListener(new View.OnClickListener() {
       @Override
       public void onClick(View v) {
           getFragmentManager().beginTransaction()
                   .replace(R.id.id_content_view,new CarPeccancyFragment())
                   .commit();
       }
   });


    }
}
